//
//  DHConfigViewController.m
//  宏达APP
//
//  Created by DIANGHONG on 2018/5/7.
//  Copyright © 2018年 123. All rights reserved.
//

#import "DHConfigViewController.h"
#import "DHConfigHeaderView.h"

NSString *NoneGoodCellID = @"NoneGoodCellID";
@interface DHConfigViewController ()

@end

@implementation DHConfigViewController

- (void)setConfigList:(NSArray *)configList{
    _configList = configList;
    
    [self.tableView reloadData];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cellid"];
    [self.tableView registerNib:[UINib nibWithNibName:@"DHNoneGoodCell" bundle:nil] forCellReuseIdentifier:NoneGoodCellID];
    [self.tableView setRowHeight:100];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.configList.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NoneGoodCellID forIndexPath:indexPath];
    //cell.textLabel.text = self.configList[indexPath.section][@"gc_name"];
    
    return cell;
}

#pragma mark: - table view delegate
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [self creatHeaderViewWithSection:section];//[[UIView alloc]init];//[self creatHeaderViewWitnSection:section];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点到我了");
}

#pragma mark: - 创建headerView
- (UIView *)creatHeaderViewWithSection:(NSInteger)section{
    
    DHConfigHeaderView *headerV = [DHConfigHeaderView headerViewWithTitle:self.configList[section][@"gc_name"]];
    
    return headerV;
}



@end
